package utils

import (
	"bytes"
	"encoding/json"
	"finance/config"
	"net/http"
	"time"
)

func DeepSeekRequest(payload interface{}) (map[string]interface{}, error) {
	data, _ := json.Marshal(payload)

	req, _ := http.NewRequest("POST", config.AppConfig.DeepSeek.APIUrl, bytes.NewBuffer(data))
	req.Header.Set("Authorization", "Bearer "+config.AppConfig.DeepSeek.ApiKey)
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: config.AppConfig.DeepSeek.Timeout * time.Second}
	resp, err := client.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	var result map[string]interface{}
	json.NewDecoder(resp.Body).Decode(&result)
	return result, nil
}
